package com.minshenglife.zanzan.web.weixin;

import javax.servlet.http.HttpServletRequest;


import com.nationsky.pub.utils.StringUtils;



/**
 * 
 * @author huodd
 * 
 */
public class BaseController {
	
	/**
	 * 获取empId
	 * 先从request.getAttribute("empId")中获取，未果，再从request.getParameter("empId")中获取
	 * @param request
	 * @return
	 */
   public static String getEmpId(HttpServletRequest request){
	   System.out.println(request.getAttribute("empId"));
	   Object empId="";
	   empId=request.getAttribute("empId");
	   if(StringUtils.isNullOrEmpty(String.valueOf(empId))){
		   Object str=request.getParameter("empId");
		   if(StringUtils.isNullOrEmpty(String.valueOf(str)))
			   empId=String.valueOf(str); 
	   }
	   return String.valueOf(empId);
   }
   /**
	 * 获取openId
	 * 先从request.getParameter("openId")中获取，未果，再从request.getAttribute("openId")中获取
	 * @param request
	 * @return
	 */
   public static String getOpenId(HttpServletRequest request){
	   String openId="";
	   openId=request.getParameter("openId");
	   if(StringUtils.isNullOrEmpty(openId)){
		   Object str=request.getAttribute("openId");
		   if(StringUtils.isNullOrEmpty(openId))
			   openId=String.valueOf(str); 
	   }
	   return openId;
   }
   /**
 	 * 获取appid
 	 * 先从request.getParameter("appid")中获取，未果，再从request.getAttribute("appid")中获取
 	 * @param request
 	 * @return
 	 */
    public static String getAppid(HttpServletRequest request){
 	   String appid="";
 	  appid=request.getParameter("appid");
 	   if(StringUtils.isNullOrEmpty(appid)){
 		   Object str=request.getAttribute("appid");
 		   if(StringUtils.isNullOrEmpty(appid))
 			  appid=String.valueOf(str); 
 	   }
 	   return appid;
    }
}
